package com.cheboohui.iqs.deal;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.alibaba.fastjson.JSONObject;
import com.cheboohui.iqs.config.Config;
import com.cheboohui.iqs.menu.ErrorNews;
import com.cheboohui.iqs.spring.entity.price.request.CheckCar;
import com.cheboohui.iqs.spring.entity.price.request.ConfirmInsured;
import com.cheboohui.iqs.spring.entity.price.request.PayRequest;
import com.cheboohui.iqs.spring.entity.price.request.PriceRequest;
import com.cheboohui.iqs.spring.entity.price.response.CheckCarResult;
import com.cheboohui.iqs.spring.entity.price.response.ConfirmInsuredResult;
import com.cheboohui.iqs.spring.entity.price.response.PriceResult;
import com.cheboohui.iqs.test.TestPrice;

/**
 * 报价相关接口处理
 * 
 * @author xielonghai
 *
 */
public class PriceDeal {
	/**
	 * logger:日志工具.
	 */
	private static Log log = LogFactory.getLog(PriceDeal.class);

	/**
	 * 车险保费车辆查询
	 * 
	 * @param checkCar
	 * @return
	 */
	public static CheckCarResult checkCar(CheckCar checkCar) {
		log.info("进入" + Config.value + ",车险车辆查询接口...");
		try {
			CheckCarResult result =TestPrice.checkCar(checkCar);
					//new CheckCarResult(ErrorNews.L03, "暂不提供该接口");
			log.info(Config.value + ",车险车辆查询接口查询结果:" + JSONObject.toJSONString(result));
			return result;
		} catch (Exception e) {
			log.error(Config.value + ",车险车辆查询出现异常" + e);
			return new CheckCarResult(ErrorNews.L03, "车险车辆查询接口异常:" + e.getMessage());
		}

	}

	/**
	 * 车险保费计算
	 * 
	 * @param priceRequest
	 * @return
	 */
	public static PriceResult carPrice(PriceRequest priceRequest) {
		log.info("进入" + Config.value + ",车险报价接口...");
		try {
			PriceResult result = TestPrice.carPrice(priceRequest);
					//new PriceResult(ErrorNews.L03, "暂不提供该接口");
			log.info(Config.value + ",车险保费计算接口结果:" + JSONObject.toJSONString(result));
			return result;
		} catch (Exception e) {
			log.error(Config.value + ",车险报价出现异常" + e);
			return new PriceResult(ErrorNews.L03, "车险报价接口异常:" + e.getMessage());
		}

	}

	/**
	 * 车险确认投保
	 * 
	 * @param confirmInsured
	 * @return
	 */
	public static ConfirmInsuredResult confirm(ConfirmInsured confirmInsured) {
		log.info("进入" + Config.value + ",车险确认投保接口...");
		try {
			ConfirmInsuredResult result =//TestPrice.confirm(confirmInsured);
					new ConfirmInsuredResult(ErrorNews.L03, "暂不提供该接口");
			log.info(Config.value + ",车险确认投保接口结果:" + JSONObject.toJSONString(result));
			return result;
		} catch (Exception e) {
			log.error(Config.value + ",车险确认投保出现异常" + e);
			return new ConfirmInsuredResult(ErrorNews.L03, "车险确认投保接口异常:" + e.getMessage());
		}
	}

	/**
	 * 车险支付登记
	 * 
	 * @param payRequest
	 * @return
	 */
	public static ConfirmInsuredResult pay(PayRequest payRequest) {
		log.info("进入" + Config.value + ",车险支付登记接口...");
		try {
			ConfirmInsuredResult result =//TestPrice.pay(payRequest);
					new ConfirmInsuredResult(ErrorNews.L03, "暂不提供该接口");
			log.info(Config.value + ",车险支付登记接口结果:" + JSONObject.toJSONString(result));
			return result;
		} catch (Exception e) {
			log.error(Config.value + ",车险支付登记出现异常" + e);
			return new ConfirmInsuredResult(ErrorNews.L03, "车险支付登记接口异常:" + e.getMessage());
		}
	}
}
